using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameLaunch : MonoBehaviour
{
    public Role Prefab;
    public BoxCollider Box;

    private Bounds m_Bounds;
    public float Internal = 1;
    private float m_Time;

    public List<Role> Roles = new List<Role>();
    void Start()
    {
        m_Bounds = Box.bounds;

        for (int i = 0; i < 1; i++)
        {
            var role = MonoBehaviour.Instantiate<Role>(Prefab);
            role.Init();
            role.OnDead = () =>
            {
                role.Init();
            };

            Roles.Add(role);
        }
    }

    // Update is called once per frame
    void Update()
    {
        m_Time += Time.deltaTime;
        if (m_Time >= Internal)
        {
            for (int i = 0; i < Roles.Count; i++)
            {
                Roles[i].ReduceHP(Random.Range(1, 60));
            }
            m_Time = 0;
        }

        for (int i = 0; i < Roles.Count; i++)
        {
            Roles[i].Move(m_Bounds);
        }
    }
}
